.class public final Llt/noframe/gpsfarmguide/import_fields/imports/FieldsDBImporter;
.super Lio/reactivex/Single;
.source "FieldsDBImporter.kt"


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "Lio/reactivex/Single<",
        "Ljava/lang/Boolean;",
        ">;"
    }
.end annotation

.annotation system Ldalvik/annotation/SourceDebugExtension;
    value = "SMAP\nFieldsDBImporter.kt\nKotlin\n*S Kotlin\n*F\n+ 1 FieldsDBImporter.kt\nlt/noframe/gpsfarmguide/import_fields/imports/FieldsDBImporter\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,30:1\n1591#2,3:31\n*E\n*S KotlinDebug\n*F\n+ 1 FieldsDBImporter.kt\nlt/noframe/gpsfarmguide/import_fields/imports/FieldsDBImporter\n*L\n16#1,3:31\n*E\n"
.end annotation


# instance fields
.field private final list:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Ljava/util/List;)V
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;",
            ">;)V"
        }
    .end annotation

    const-string v0, "list"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 13
    invoke-direct {p0}, Lio/reactivex/Single;-><init>()V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/import_fields/imports/FieldsDBImporter;->list:Ljava/util/List;

    return-void
.end method


# virtual methods
.method protected subscribeActual(Lio/reactivex/SingleObserver;)V
    .locals 8
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lio/reactivex/SingleObserver<",
            "-",
            "Ljava/lang/Boolean;",
            ">;)V"
        }
    .end annotation

    const-string v0, "observer"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 16
    iget-object v0, p0, Llt/noframe/gpsfarmguide/import_fields/imports/FieldsDBImporter;->list:Ljava/util/List;

    .line 32
    invoke-interface {v0}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v0

    const/4 v1, 0x0

    const/4 v2, 0x0

    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_2

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    add-int/lit8 v4, v2, 0x1

    if-ltz v2, :cond_1

    check-cast v3, Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;

    .line 17
    invoke-virtual {v3}, Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;->getShapeModel()Llt/farmis/libraries/shape_import_android/models/ShapeModel;

    move-result-object v5

    invoke-virtual {v5}, Llt/farmis/libraries/shape_import_android/models/ShapeModel;->getName()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v5

    if-eqz v5, :cond_0

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v6, "IMPORTED "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    goto :goto_1

    :cond_0
    invoke-virtual {v3}, Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;->getShapeModel()Llt/farmis/libraries/shape_import_android/models/ShapeModel;

    move-result-object v2

    invoke-virtual {v2}, Llt/farmis/libraries/shape_import_android/models/ShapeModel;->getName()Ljava/lang/String;

    move-result-object v2

    .line 19
    :goto_1
    new-instance v5, Llt/noframe/gpsfarmguide/models/MeasuringModel;

    new-instance v6, Llt/noframe/gpsfarmguide/models/PolygonModel;

    invoke-direct {v6}, Llt/noframe/gpsfarmguide/models/PolygonModel;-><init>()V

    const/4 v7, 0x2

    invoke-direct {v5, v6, v7}, Llt/noframe/gpsfarmguide/models/MeasuringModel;-><init>(Llt/noframe/gpsfarmguide/interfaces/Shape;I)V

    .line 20
    invoke-virtual {v5, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setId(I)V

    .line 21
    invoke-virtual {v5, v2}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setName(Ljava/lang/String;)V

    .line 22
    invoke-virtual {v5, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setGroup(I)V

    .line 23
    invoke-virtual {v3}, Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;->getCoordinatesList()Ljava/util/List;

    move-result-object v2

    invoke-virtual {v5, v2}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->setPoints(Ljava/util/List;)V

    .line 24
    invoke-static {}, Ljava/util/UUID;->randomUUID()Ljava/util/UUID;

    move-result-object v2

    invoke-virtual {v2}, Ljava/util/UUID;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v5, v2}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setUniqueId(Ljava/lang/String;)V

    .line 26
    invoke-static {}, Llt/noframe/gpsfarmguide/database/DB;->getDB()Llt/noframe/gpsfarmguide/database/DB;

    move-result-object v2

    invoke-virtual {v2, v5}, Llt/noframe/gpsfarmguide/database/DB;->insertArea(Llt/noframe/gpsfarmguide/models/MeasuringModel;)J

    move v2, v4

    goto :goto_0

    .line 32
    :cond_1
    invoke-static {}, Lkotlin/collections/CollectionsKt;->throwIndexOverflow()V

    const/4 p1, 0x0

    throw p1

    :cond_2
    const/4 v0, 0x1

    .line 28
    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    invoke-interface {p1, v0}, Lio/reactivex/SingleObserver;->onSuccess(Ljava/lang/Object;)V

    return-void
.end method
